package com.windoent.yugioh.adapter.brvah;

import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.windoent.yugioh.R;
import com.windoent.yugioh.bean.OnGoingHasEndLunBean;
import com.windoent.yugioh.utils.BaseMethod;
import com.windoent.yugioh.utils.SimpleUtils;
import com.windoent.yugioh.widget.RoundImageView;

/**
 * author : robert
 * date   : 2021/5/6 15:26
 * desc   :
 */
public class OnGoingHasEndSaiGuoLunsAdapter extends BaseQuickAdapter<OnGoingHasEndLunBean.DataBean.CurrentUserBean, BaseViewHolder> {

    public OnGoingHasEndSaiGuoLunsAdapter() {
        super(R.layout.item_ongoing_hasend_luns, null);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, OnGoingHasEndLunBean.DataBean.CurrentUserBean item) {
        helper.setText(R.id.tv_name, BaseMethod.notNullDefaultValueNull(item.getNickname()))
                .setText(R.id.tv_paiming, BaseMethod.notNullDefaultValueNull(item.getRank() + ""))
                .setText(R.id.tv_point, BaseMethod.notNullDefaultValueNull(item.getScore() + ""))
                .setText(R.id.tv_breaker, BaseMethod.notNullDefaultValueNull(item.getTiebreaker()));
        RoundImageView iv_avatar = helper.getView(R.id.iv_avatar);
        SimpleUtils.loadImageForView(getContext(), iv_avatar, item.getAvatar(), R.drawable.img_official_avatar_android);

        LinearLayout parent = helper.getView(R.id.ll_parent);
        int layoutPosition = helper.getLayoutPosition();
        if (layoutPosition == getData().size()) {
            parent.setBackgroundResource(layoutPosition % 2 == 0 ? R.drawable.drawable_adapter_baoming_shenhe_gray_corner_bg : R.drawable.drawable_adapter_baoming_shenhe_normal_color_bg);
        } else {
            parent.setBackgroundResource(layoutPosition % 2 == 0 ? R.drawable.drawable_adapter_baoming_shenhe_gray_bg : R.drawable.drawable_adapter_baoming_shenhe_normal_bg);
        }
    }
}